<?php
$head_httpdvb = 'http://httpdvb.slave.yqdtv.com:13164/playurl';
$head_httpstream = 'http://stream.slave.yqdtv.com:13164/playurl';
//$head_rtsp = 'rtsp://vod.slave.yqdtv.com:554/playurl';

$accesstoken=array('G981B7E55V21307D1TC06273J4D0002ABM786ACE0AI7A07A0DEK98BDA6','G7E1BC473V21307D1T37C06273JF00002ABM786ACE0AI7A07A0DEK98BDA6','G331C72D3V21307D1T206251J729402ABM786AD2D2I39659027K98BDA6','G171CCF47V21307D1TE06202J347C03ABM7902F3A5I2A659027K98BDA6');

$id=isset($_GET['id'])?$_GET['id']:'001';

$url = 'http://slave.yqdtv.com:13160/media/channel/get_info?chnlid=4200000'.$id.'&accesstoken='.$accesstoken[mt_rand(0,count($accesstoken)-1)];
$result = file_get_contents($url);
$json = json_decode($result);
$playtoken = $json->play_token;

$start='';
$end='';
$isplayback=false;
if(isset($_GET['start'])&isset($_GET['end'])){
    $start=$_GET['start'];
    $end=$_GET['end'];
    $pf_id=$json->pf_info[0]->id;
    $isplayback=true;
}

if($isplayback){
    $playurl=$head_httpstream.'?playtype=lookback&protocol=hls&starttime='.$start.'&endtime='.$end.'&accesstoken='.$accesstoken[mt_rand(0,count($accesstoken)-1)].'&programid='.$pf_id.'&playtoken='.$playtoken;
}else{
    $playurl=$head_httpdvb.'?playtype=live&protocol=hls&accesstoken='.$accesstoken[mt_rand(0,count($accesstoken)-1)].'&programid=4200000'.$id.'&playtoken='.$playtoken;
}

header("location: ".$playurl);
?>